<template>
	<view class="content">
		<uni-collapse>
			<uni-collapse-item :title="item" v-for="(item, index) in timeList" :key="index" @click.native="detail(item)">
				<view style="padding: 30rpx;">
					<my-sign-calendar
						:signData="signData"
						:signList="signList"
						@callbackSign="callbackSign"
					></my-sign-calendar>
				</view>
			</uni-collapse-item>
		</uni-collapse>
	</view>
</template>

<script>
import http from '@/common/request.js';
import { getCommonShareInfo } from '@/common/utils.js';
import mySignCalendar from '@/components/my-sign-calendar/my-sign-calendar'
export default {
	onShareAppMessage() {
		return getCommonShareInfo()
	},
	components: {
	  mySignCalendar
	},
	data() {
		return {
			signData: {
				start: '2018-08-01', // 开始的日期（yyyy-mm-dd），默认‘2019-08-01’
				ismake: true, // 是否开启补签
				type: 'month' // 日历模式（月 => month，周 => week）
			},
			signList: [],
			timeList: []
		};
	},
    onLoad() {
      this.getAjax()
	  this.list()
    },
    methods: {
		list() {
			http('/api/cusUserInfo/getCheckDetailsDate', {data: {}, method: 'GET'}).then(
				result => {
					let data = result.data
					this.timeList = data.times
				},
				result => {
					this.showLoading = false
					uni.showToast({
						title: result.msg,
						icon: 'none'
					})
				}
			)
		},
		getAjax() {
			// 获取签到数据
			this.signList = [{ year: '2020', month: '3', day: '1'}, 
				{ year: '2020', month: '3', day: '10'}, 
				{ year: '2020', month: '4', day: '1'}, 
				{ year: '2020', month: '4', day: '3'}, 
				{ year: '2020', month: '4', day: '4'}, 
				{ year: '2020', month: '4', day: '5'},
				{ year: '2020', month: '4', day: '12'}
			]
		},
		detail(time) {
			http('/api/cusUserInfo/getCheckDetailsByCustomerId', {data: {queryTime: time}, method: 'GET'}).then(
				result => {
					let data = result.data
				},
				result => {
					this.showLoading = false
					uni.showToast({
						title: result.msg,
						icon: 'none'
					})
				}
			)
		},
		// 签到回调
		callbackSign(data) {
			// ajax请求，更新this.signList数据
			uni.showToast({
			  title: data.msg,
			  icon: 'none'
			})
		}
    }
}
</script>

<style lang="less" scoped>
	
  .content {
    padding: 20upx 0;
	.title {
		font-size: 36rpx;
		color: #66645D;
		font-weight:500;
	}
  }
  .uni-collapse-cell {
	  border: none !important;
	  margin: 24rpx 28rpx 0 28rpx;
  }
 /deep/.uni-collapse-cell__title {
	height: 88rpx;
	background: #fff;
	border: none;
	// margin: 24rpx 28rpx 0 28rpx;
	// padding: 0 24rpx;
  }
  /deep/.uni-collapse-cell__content {
  	background: #fff !important;
  }
</style>
